from django.db import models
from django.contrib.auth.models import User
from ckeditor.fields import RichTextField


class Article(models.Model):
    class Meta:
        db_table = 'Article'
        verbose_name = '文章'
        verbose_name_plural = verbose_name

    title = models.CharField(max_length=30, verbose_name='题目')
    content = RichTextField(verbose_name='内容')
    create_date_time = models.DateTimeField(auto_now_add=True, verbose_name='发表日期时间')
    create_date = models.DateField(auto_now_add=True, verbose_name='发表日期')
    create_time = models.TimeField(auto_now_add=True, verbose_name='发表时间')
    emotion = models.CharField(max_length=10, verbose_name='情绪')
    depressed = models.IntegerField(default=0, verbose_name='抑郁倾向')
    extreme = models.IntegerField(default=0, verbose_name='极端行为倾向')
    top = models.BooleanField(default=False, verbose_name='置顶')
    public = models.BooleanField(default=False, verbose_name="公开")
    anonymous = models.BooleanField(default=True, verbose_name="匿名")
    auth = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name='作者', related_name='articles')

    def __str__(self):
        return u"{}".format(self.title)
